import { IPSSubAppRef } from './ipssub-app-ref';
import { IPSAppMenuModel } from './appmenu/ipsapp-menu-model';
import { IPSAppDEUIActionGroup } from './dataentity/ipsapp-deuiaction-group';
import { IPSAppView } from './view/ipsapp-view';
import { IPSControl } from '../control/ipscontrol';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSSubAppRefImpl extends PSModelObjectImpl implements IPSSubAppRef {
  protected allpsappdeuiactiongroups: IPSAppDEUIActionGroup[] | null = null;

  getAllPSAppDEUIActionGroups(): IPSAppDEUIActionGroup[] | null {
    if (this.allpsappdeuiactiongroups == null) {
      this.allpsappdeuiactiongroups = this.fillChildListModel(this.M.getAllPSAppDEUIActionGroups, 'app.dataentity.IPSAppDEUIActionGroup') as IPSAppDEUIActionGroup[];
    }
    return this.allpsappdeuiactiongroups;
  }

  get allPSAppDEUIActionGroups(): IPSAppDEUIActionGroup[] | null {
    return this.getAllPSAppDEUIActionGroups();
  }

  findPSAppDEUIActionGroup(objKey: any): IPSAppDEUIActionGroup | null {
    return this.getPSModel5('app.dataentity.IPSAppDEUIActionGroup', this.getAllPSAppDEUIActionGroups(), objKey) as IPSAppDEUIActionGroup;
  }

  protected allpsappviews: IPSAppView[] | null = null;

  getAllPSAppViews(): IPSAppView[] | null {
    if (this.allpsappviews == null) {
      this.allpsappviews = this.fillChildListModel(this.M.getAllPSAppViews, 'app.view.IPSAppView') as IPSAppView[];
    }
    return this.allpsappviews;
  }

  get allPSAppViews(): IPSAppView[] | null {
    return this.getAllPSAppViews();
  }

  findPSAppView(objKey: any): IPSAppView | null {
    return this.getPSModel5('app.view.IPSAppView', this.getAllPSAppViews(), objKey) as IPSAppView;
  }

  protected allpsdedrcontrols: IPSControl[] | null = null;

  getAllPSDEDRControls(): IPSControl[] | null {
    if (this.allpsdedrcontrols == null) {
      this.allpsdedrcontrols = this.fillChildListModel(this.M.getAllPSDEDRControls, 'control.IPSControl') as IPSControl[];
    }
    return this.allpsdedrcontrols;
  }

  get allPSDEDRControls(): IPSControl[] | null {
    return this.getAllPSDEDRControls();
  }

  findPSControl(objKey: any): IPSControl | null {
    return this.getPSModel5('control.IPSControl', this.getAllPSDEDRControls(), objKey) as IPSControl;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get modelStamp(): string {
    return this.M.modelStamp;
  }

  get name(): string {
    return this.M.name;
  }

  protected psappmenumodel: IPSAppMenuModel | null = null;

  getPSAppMenuModel(): IPSAppMenuModel | null {
    if (this.psappmenumodel != null) return this.psappmenumodel;
    const value = this.M.getPSAppMenuModel;
    if (value == null) {
      return null;
    }
    this.psappmenumodel = this.getPSModel4('app.appmenu.IPSAppMenuModel', value, 'getPSAppMenuModel') as IPSAppMenuModel;
    return this.psappmenumodel;
  }

  get psAppMenuModel(): IPSAppMenuModel | null {
    return this.getPSAppMenuModel();
  }

  getPSAppMenuModelMust(): IPSAppMenuModel {
    const value = this.getPSAppMenuModel();
    if (value == null) {
      throw new Error('未指定应用菜单模型');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSSubAppRefImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.IPSSubAppRef') return true;
    return super.instanceof(cls);
  }
}
